#include<bits/stdc++.h>
using namespace std;
string a,b,c;
int rep[200],used[10];
int alen,blen,clen;
int addd(int now)
{
	int ret=0;
	if(now<alen)
		ret+=rep[a[now]];
	if(now<blen)
		ret+=rep[b[now]];
	return ret;
}
void dfs(int now,int st,int mo)
{
	if(st==1)
	{
		if(now==clen&&!mo)
		{
			for(int i=alen-1;i>=0;--i)
				cout<<rep[a[i]];
			cout<<endl;
			for(int i=blen-1;i>=0;--i)
				cout<<rep[b[i]];
			cout<<endl;
			for(int i=clen-1;i>=0;--i)
				cout<<rep[c[i]];
			cout<<endl;
			exit(0);
		}
		if(now>=alen)
			dfs(now,2,mo);
		else
			if(rep[a[now]]==-1)
				for(int i=(now==alen-1);i<=9;++i)
				{
					if(!used[i])
					{
						rep[a[now]]=i;
						used[i]=1;
						dfs(now,2,mo);
						rep[a[now]]=-1;
						used[i]=0;
					}
				}
			else
				dfs(now,2,mo);
	}
	if(st==2)
	{
		if(now>=blen)
			dfs(now,3,mo);
		else
			if(rep[b[now]]==-1)
				for(int i=(now==blen-1);i<=9;++i)
				{
					if(!used[i])
					{
						rep[b[now]]=i;
						used[i]=1;
						dfs(now,3,mo);
						rep[b[now]]=-1;
						used[i]=0;
					}
				}
			else
				dfs(now,3,mo);
	}
	if(st==3)
	{
		if(rep[c[now]]==-1)
		{
			int x=addd(now)+mo;
			mo=x/10,x%=10;
			if(used[x]||now==clen-1&&x==0)
				return;
			rep[c[now]]=x;
			used[x]=1;
			dfs(now+1,1,mo);
			rep[c[now]]=-1;
			used[x]=0;
		}
		else
		{
			int x=addd(now)+mo;
			mo=x/10,x%=10;
			if(x!=rep[c[now]]||now==clen-1&&x==0)
				return;
			dfs(now+1,1,mo);
		}
	}
}
int main()
{
	cin>>a>>b>>c;
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	reverse(c.begin(),c.end());
	alen=a.length(),blen=b.length(),clen=c.length();
	memset(rep,-1,sizeof(rep));
	if(alen>clen||blen>clen||clen>alen+1&&clen>blen+1)
	{
		puts("UNSOLVABLE");
		return 0;
	}
	dfs(0,1,0);
	puts("UNSOLVABLE");
	return 0;
}
